<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="lib/vue-2.4.0.js"></script>
</head>
<body>
<div id="app">
    <div :style="{fontSize:fontSize+'px'}">{{pmsg}}</div>
    <menu-item :parr="parr" @enlarge-text="handle($event)"></menu-item>
</div>
<script>
    Vue.component('menu-item',{
        props:['parr'],
        template:`<div>
                    <ul>
                        <li v-for="item in parr">{{item}}</li>
                    </ul>
                    <button @click="parr.push('lemon')">点击</button>
                    <button @click="$emit('enlarge-text',5)">扩大父组件字体大小+5</button>
                    <button @click="$emit('enlarge-text',10)">扩大父组件字体大小+10</button>
                    <button @click="$emit('enlarge-text',20)">+20</button>
                  </div>`
    })
    var vm=new Vue({
        el:'#app',
        data:{
            pmsg:'父组件内容',
            parr:['apple','orange','banana'],
            fontSize:10
        },
        methods:{
            handle(val){
                // 扩大字体大小
                this.fontSize+=val
            }
        }
    })
</script>
</body>
</html>